home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / pump_src / setup / asciiz.pas next >
Encoding:
Pascal/Delphi Source File  |  1994-07-04  |  1.8 KB  |  63 lines

  1. {****************************************************************************}
  2. {                                                                            }
  3. { MODULE:         AsciiZ                                                     }
  4. {                                                                            }
  5. { DESCRIPTION:    Provides a conversion function   AsciiZ -> string.         }
  6. {                                                                            }
  7. { AUTHOR:         Juan Carlos ArĂ©valo                                        }
  8. {                                                                            }
  9. { MODIFICATIONS:  Nobody (yet ;-).                                           }
  10. {                                                                            }
  11. { HISTORY:        01-Oct-1992 First documentation.                           }
  12. {                 17-Oct-1992 Documentation finished.                        }
  13. {                                                                            }
  14. { (C) 1992 VangeliSTeam                                                      }
  15. {____________________________________________________________________________}
  16.  
  17. {$O+,F+}
  18.  
  19. UNIT AsciiZ;
  20.  
  21. INTERFACE
  22.  
  23.  
  24.  
  25.  
  26. FUNCTION StrAsciiZ(VAR s; l: WORD) : STRING; { Converts the AsciiZ string 's' to a }
  27.                                              { TP string with a maximum length.    }
  28.  
  29.  
  30.  
  31.  
  32. IMPLEMENTATION
  33.  
  34.  
  35.  
  36.  
  37. FUNCTION StrAsciiZ(VAR s; l: WORD) : STRING;
  38.   VAR
  39.     z : ARRAY[0..65520] OF CHAR ABSOLUTE s;
  40.     i : WORD;
  41.   BEGIN
  42.     i := 0;
  43.  
  44.     IF z[0] <> #0 THEN
  45.       REPEAT
  46.         StrAsciiZ[i+1] := z[i];
  47.         INC(i);
  48.       UNTIL (i > l) OR (z[i] = #0);
  49.  
  50.     IF i > l THEN DEC(i);
  51.  
  52.     StrAsciiZ[0] := CHR(l);
  53.  
  54.     IF i < l THEN
  55.       FOR i := i+1 TO l DO
  56.         StrAsciiZ[i] := ' ';
  57.   END;
  58.  
  59.  
  60.  
  61.  
  62. END.
  63.